<# # It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description: Script is designed To Set User based registry key at computer based deployment # Configuration Type - COMPUTER # Note: The regsitry hive details needs to be hardcoded here #> $name = (Get-WMIObject -ClassName Win32_ComputerSystem).Username $sid = (New-Object System.Security.Principal.NTAccount($name)).Translate([System.Security.Principal.SecurityIdentifier]).value $null = New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS -ErrorAction SilentlyContinue # Define the path to the registry key (The values Need to be hardcoded here) $registryPath = "HKU:\$sid\SOFTWARE\Policies\Test" # Change the hive value after the $sid $propertyValueName = "Test" $propertyValueData = "1" $propertyValueType = "DWord" # Check if the folder exists, create it if it doesn't if (-not (Test-Path $registryPath)) { New-Item -Path $registryPath -ItemType Directory -Force } # Set the registry value $null = New-ItemProperty -Path $registryPath -Name $propertyValueName -Value $propertyValueData -PropertyType $propertyValueType -Force Write-Host "The User Based registry value was set successfully via computer based deployment"